﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>添加模板</title>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushJScript.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>添加模板数据</h3>
    每一个视图都要配置视图数据，其类型为泛型类型
    NFinal.View.RazorView&lt;string>就代表其视图数据类型为string.
    <pre class="brush:js;html-script:true;">
    @inherits NFinal.View.RazorView&lt;string>
    &lt;!DOCTYPE html>
    &lt;html>
    &lt;head>
        &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        &lt;title>&lt;/title>
        &lt;meta http-equiv="Cache-Control" content="no-cache">
    &lt;/head>
    &lt;body>
    @Model
    &lt;/body>
    &lt;/html>
    </pre>
    <p>我们把视图类型更改为Index控制器下的Index操作自动生成的视图类型，<br/>
    即Index1Controller.model.cs文件中的Index类型<br/>
    <img src="../../../Content/images/rumen/20171124130354.png"/><br />
    </p>
    Index1Controller.model.cs文件的内容为：<br />
    <pre class="brush:csharp;">
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NFinal;
    //此代码由NFinalCompiler生成。
    //http://bbs.nfinal.com
    namespace NFinalWeb3.Controllers.Index1Controller_Model
    {
	    public class Index
	    {
		    [NFinal.ViewBagMember]
		    [Newtonsoft.Json.JsonIgnore]
            //当前插件的配置文件信息
		    public NFinal.Config.Plug.PlugConfig config;
		    public int Code;
		    public string Message;
	    }
    }
    </pre>
    切换视图类型为控制器操作的视图类型并保存<br/>
    <pre class="brush:js;html-script:true;">
    @inherits NFinal.View.RazorView&lt;NFinalWeb3.Controllers.Index1Controller_Model.Index>
    &lt;!DOCTYPE html>
    &lt;html>
    &lt;head>
        &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        &lt;title>&lt;/title>
        &lt;meta http-equiv="Cache-Control" content="no-cache">
    &lt;/head>
    &lt;body>
    @Model
    &lt;/body>
    &lt;/html>
    </pre>
</body>
</html>